## Script (Python) "tree"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##title=Generate concept tree
##parameters=top=None,level=0,list=None,siblingsBelow=0

if top is None: top = context
if list is None: list = []
list.append({'level':level, 
             'title':top.Title(), 
             'url':top.absolute_url(),
             'siblingsBelow':siblingsBelow
             })
levelList = top.listNarrower()
for num, concept in enumerate(levelList):
    siblingsBelow = (len(levelList) - 1) - num
    context.tree(concept,level+1,list,siblingsBelow)    

return list